import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ZhongJinTao
 * Date: 2024-03-05
 * Time: 9:08
 */
public class IODemo3 {
    public static void main(String[] args){
        try(InputStream inputStream = new FileInputStream("./test.txt")){
            while (true) {
                byte[] buffer = new byte[1024];
                int n = inputStream.read(buffer, 0, 2);
                if(n == 0) {
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.print((char)buffer[i]);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
